All Questions
Tagged with coding-stylereadability
39 questions
0votes
4answers
396views
Code quality: expressiveness vs. conciseness
I've been wondering about code expressiveness vs. conciseness lately. What I mean by that is that a lot of modern programming languages offer features to express statements in a very short manner, ...
1vote
2answers
267views
What is an appropriate length for function names? [closed]
I'm writing a C++ class, CBookSpellDef which has the following methods: int GetIndexOf(const char *psz); char* GetNameAtIndex(int index) { return m_spellTypes[index].szName; } char* ...
2votes
1answer
608views
Does "happy path to the left edge" break Python conventions?
I found the short article Align the happy path to the left edge quite helpful in improving readability of functions. Briefly, reading down the left edge of the function should step you through the ...
0votes
1answer
328views
Is there a reason why you shouldn't use 'integration variables'?
I tend to create a variable whenever I need an uncircumstantially same value as to that of an earlier value more than once (the values are not happening to be the same by chance rather they actually ...
-4votes
1answer
837views
Is using yoda conditions with c# justified?
It's mind bending experiencing reading code like : "Aggregation".Equals(evt.Id)) I was unsuccessful in trying to talk the person out of this style, maybe I'm wrong? Or maybe I wasn't articulate ...
2votes
2answers
149views
How should I call splitted functions? centralize them? or call it one next to one?
According to Is it OK to split long functions and methods into smaller ones even though they won't be called by anything else?, I should split long functions into smaller functions even if they ...
1vote
2answers
4kviews
Using the same name for setter and gettter methods for a boolean member variable
Say I have class with a boolean member variable fancy: public class MyClass { private boolean fancy; } Case 1. I could the define the setter and getter as follows: // getter public boolean ...
4votes
5answers
1kviews
Is it a bad practice to use conditionals with functions that change program's state?
The title might be a bit vague, so let me explain. Let's assume we have a function that does something (changes state of the program), for example a function that creates a file. That function returns ...
63votes
10answers
12kviews
Readability versus maintainability, special case of writing nested function calls
My coding style for nested function calls is the following: var result_h1 = H1(b1); var result_h2 = H2(b2); var result_g1 = G1(result_h1, result_h2); var result_g2 = G2(c1); var a = F(result_g1, ...
0votes
1answer
319views
Do all Get/SetAccess, Access, and Dependent property attribute combinations have valid use cases?
If You are Unfamiliar with OOP Matlab For those not familiar with matlab, matlab provides a variety of access attributes when creating member variables. All member variables are essentially C# ...
1vote
1answer
191views
How to write Readable Comment when we have to deal with IDs?
How to write Readable Comment when we have to deal with IDs? I will explain this with example. +---------------+-----------------+ | permission_id | permission_name | +---------------+--------------...
147votes
6answers
17kviews
Are private methods with a single reference bad style?
Generally I use private methods to encapsulate functionality that is reused in multiple places in the class. But sometimes I have a large public method that could be broken up into smaller steps, each ...
1vote
3answers
188views
Should conditionals be embedded in the function whose execution is contingent on them?
I have a large data structure that is about to be persisted to the database. Before that can happen I have to validate it and then update a bunch of it's properties based on various specific ...
1vote
2answers
5kviews
SonarQube is complaining about: "Use isEmpty() to check whether the collection is empty or not."
So as my the title says, SonarQube is complaining whenever you use list.size() == 0 or list.size > 0 However I started changing to isEmpty() and !is.Empty() and noticed the code becomes way ...
0votes
1answer
227views
What scientific support does some coding standards have?
Let's consider the rule in python PEP8, coding standard for the linux kernel etc saying that a line of code are not allowed to be longer than N characters. To this rule there is normally a few ...